//
//  FPCriticCell.m
//  FilmParadise
//
//  Created by lanou3g on 15/7/18.
//  Copyright (c) 2015年 DLYgroup. All rights reserved.
//

#import "FPCriticCell.h"

@implementation FPCriticCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.title = [[UILabel alloc]initWithFrame:CGRectMake(kImageW(10), kImageW(10), kScreenWidth - kImageW(10), kImageH(30))];
      //  self.title.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_title];
        
        self.summary = [[UILabel alloc]initWithFrame:CGRectMake(kImageW(10), self.title.height + self.title.y, kScreenWidth - 3 *kImageW(10) - kImageW(50), kImageH(30))];
        self.summary.numberOfLines = 0;
        self.summary.font = [UIFont systemFontOfSize:11];
      //    self.summary.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_summary];
        
        self.userImage = [[UIImageView alloc]initWithFrame:CGRectMake(kImageW(10), self.summary.y + self.summary.height + kImageH(10), kImageW(20), kImageW(20))];
     //   self.userImage.backgroundColor = [UIColor redColor];
        self.userImage.layer.cornerRadius = self.userImage.bounds.size.height/2;
          self.userImage.backgroundColor = [UIColor redColor];
        self.userImage.layer.masksToBounds = YES;
        [self.contentView addSubview:_userImage];
        self.nickname = [[UILabel alloc]initWithFrame:CGRectMake(self.userImage.width+self.userImage.x + kImageW(10) ,  self.userImage.y, kScreenWidth - 6 *kImageW(10) - kImageW(50) - self.userImage.width, kImageH(20))];
        self.nickname.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:_nickname];
        
        self.rating = [[UILabel alloc]initWithFrame:CGRectMake(self.nickname.width + self.nickname.x +kImageW(10), self.nickname.y, kImageW(20), kImageW(20))];
        self.rating.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:_rating];
        CGFloat filmImageH = self.nickname.y + self.nickname.height - self.summary.y;
        self.Filmimage =[[UIImageView alloc]initWithFrame:CGRectMake(self.summary.x + self.summary.width + kImageW(10), self.summary.y , kImageW(50), filmImageH)];
     //   self.Filmimage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_Filmimage];
    }
    return self;
}
//nickname自适应宽度
- (void)adjustSubviewsWithContent:(FPFilmModel *)Fmodel model:(FPObserverModel *)model
{
    
   NSString *str = [NSString stringWithFormat:@"%@-评<<%@>>",model.nickname,Fmodel.title];
       self.title.text = model.title;
        self.summary.text = model.summary;//[NSURL URLWithString:model.userImage]
        [self.userImage sd_setImageWithURL:[NSURL URLWithString:model.userImage] placeholderImage:[UIImage imageNamed:@"noImage"] completed:nil];
    self.rating.text = model.rating;
    [self.Filmimage sd_setImageWithURL:[NSURL URLWithString:Fmodel.image] placeholderImage:[UIImage imageNamed:@"noImage"] completed:nil];
    self.nickname.text = str;
    CGRect bounds = [str boundingRectWithSize:CGSizeMake(1000 , kImageH(20)) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:11] forKey:NSFontAttributeName] context:nil];
    CGRect frame = self.nickname.frame;
    frame.size.width = bounds.size.width;
    self.nickname.frame = frame;
    self.rating.x = self.nickname.width+self.nickname.x;

  
    
    
}

@end
